package com.aidex.biz.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.biz.domain.BizAssessToDeptDetailsFile;
import com.aidex.biz.service.BizAssessToDeptDetailsFileService;
import com.aidex.common.utils.SecurityUtils;

/**
 * 考核部门文件Controller
 * @author sean
 * @email 2074844820@qq.com
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/biz/bizAssessToDeptDetailsFile")
public class BizAssessToDeptDetailsFileController extends BaseController
{
    @Autowired
    private BizAssessToDeptDetailsFileService bizAssessToDeptDetailsFileService;

    /**
     * 查询考核部门文件列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:list')")
    @GetMapping("/list")
    public R<PageInfo> list(BizAssessToDeptDetailsFile bizAssessToDeptDetailsFile, HttpServletRequest request, HttpServletResponse response)
    {

        bizAssessToDeptDetailsFile.setPage(new PageDomain(request, response));
        return R.data(bizAssessToDeptDetailsFileService.findPage(bizAssessToDeptDetailsFile));
    }

    /**
     * 获取考核部门文件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:query')")
    @GetMapping(value = "/{id}")
    public R<BizAssessToDeptDetailsFile> detail(@PathVariable("id") String id)
    {
        return R.data(bizAssessToDeptDetailsFileService.get(id));
    }

    /**
     * 新增考核部门文件
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:add')")
    @Log(title = "考核部门文件", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  BizAssessToDeptDetailsFile bizAssessToDeptDetailsFile)
    {
        return R.status(bizAssessToDeptDetailsFileService.save(bizAssessToDeptDetailsFile));
    }

    /**
     * 修改考核部门文件
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:edit')")
    @Log(title = "考核部门文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated BizAssessToDeptDetailsFile bizAssessToDeptDetailsFile)
    {
        return R.status(bizAssessToDeptDetailsFileService.save(bizAssessToDeptDetailsFile));
    }


    /**
     * 删除考核部门文件
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:remove')")
    @Log(title = "考核部门文件", businessType = BusinessType.DELETE)
    @PostMapping("/delBizAssessToDeptDetailsFile")
    public R remove(@RequestBody @Validated BizAssessToDeptDetailsFile bizAssessToDeptDetailsFile)
    {
        return R.status(bizAssessToDeptDetailsFileService.delBizAssessToDeptDetailsFile(bizAssessToDeptDetailsFile));
    }

    /**
     * 获取最大编号
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:query')")
    @GetMapping("/findMaxSort")
    public R findMaxSort()
    {
        return R.data(bizAssessToDeptDetailsFileService.findMaxSort(new BizAssessToDeptDetailsFile()));
    }

    /**
     * 导出考核部门文件列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessToDeptDetailsFile:export')")
    @Log(title = "考核部门文件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(BizAssessToDeptDetailsFile bizAssessToDeptDetailsFile)
    {

            if(SecurityUtils.isAdmin(SecurityUtils.getUserId())){
                    bizAssessToDeptDetailsFile.setCompanyId(null);
            }else{
                         bizAssessToDeptDetailsFile.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId());
                     }
        List<BizAssessToDeptDetailsFile> list = bizAssessToDeptDetailsFileService.findList(bizAssessToDeptDetailsFile);
        ExcelUtil<BizAssessToDeptDetailsFile> util = new ExcelUtil<BizAssessToDeptDetailsFile>(BizAssessToDeptDetailsFile.class);
        return util.exportExcel(list, "考核部门文件数据");
    }

}
